/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Data;


import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
/**
 *
 * @author DavidUser
 */
public class MyClipBoard {
    
    public String GetClipBoard() throws IOException{
        String result = "";
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    //odd: the Object param of getContents is not currently used
    Transferable contents = clipboard.getContents(null);
    boolean hasTransferableText =
      (contents != null) &&
      contents.isDataFlavorSupported(DataFlavor.stringFlavor)    ;
    if ( hasTransferableText ) {
      try {
        result = (String)contents.getTransferData(DataFlavor.stringFlavor);
      }
      catch (UnsupportedFlavorException | IOException ex){
        //highly unlikely since we are using a standard DataFlavor
        System.out.println(ex);
      }
    }
    return result;
  }
  
    
     
    
}
